package org.brownflat.watergate.resources.mysql;

import org.brownflat.watergate.resources.MySqlUpgrade;
import org.springframework.stereotype.Component;

/**
 * <p>&copy Rupert Jones 2011,2012</p>
 *
 * @author rup
 */
@Component
public class Upgrade0006UserRepository implements MySqlUpgrade {

    private static final int VERSION = 6;

    @Override
    public int getSequence() {
        return VERSION;
    }

    @Override
    public String getSql() {
        return "CREATE TABLE `wgate_user_repository` (\n"
                + " `id` int(11) NOT NULL AUTO_INCREMENT,\n"
                + " `user_id` int(11) NOT NULL,\n"
                + " `repository_id` int(11) NOT NULL,\n"
                + " `alias` varchar(255) NOT NULL,\n"
                + "  `created_at` timestamp NOT NULL,\n"
                + "  `updated_at` timestamp NOT NULL,\n"
                + "  PRIMARY KEY (`id`)\n"
                + ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;\n"
                + "\n"
                + "ALTER TABLE wgate_commit ADD COLUMN (user_id int(11) not null);\n";
    }

    @Override
    public String getName() {
        return "Create user repository";
    }
}
